function tickets(peopleInLine) {
    let i = 1;
    let changestack1 = []
    let changestack2 = []
    if(peopleInLine[0]==25){
        changestack1.push(25)
        while(i<peopleInLine.length){
            if(peopleInLine[i] == 25){
                changestack1.push(25)
            } else {
                if(peopleInLine[i] == 50){
                    if(changestack1.length>0){
                        changestack1.pop()
                        changestack2.push(50)
                    } else {
                        return "NO"
                    }
                } else {
                    if(changestack2.length>0){
                        if(changestack1.length>0){
                            changestack1.pop()
                            changestack2.pop()
                        } else return "NO"
                    } else {
                        if(changestack1.length>=3){
                            changestack1 = changestack1.slice(32)
                        } else return "NO"
                    }
                }
            }
            i++;
        }
        return i == peopleInLine.length?"YES":"NO"

    }
    else return "NO";
}
let arr = [50,25,25]

console.log(tickets([25, 25, 50, 50, 100]) );